package com.gusto.engine.spring.parsers;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

public class ParserProp extends AbstractBeanDefinitionParser {

	@SuppressWarnings("unchecked")
	protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
		BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(String.class);
		
		String property = "";
		if (element.hasAttribute("prefix")) {
			property += element.getAttribute("prefix");
		}
		if (element.hasAttribute("name")) {
			property += element.getAttribute("name");
		}
		beanDefinitionBuilder.addConstructorArgReference(property);
		return beanDefinitionBuilder.getBeanDefinition();
	}
}
